package com.moore.controller;

import com.moore.dto.ResponseData;
import com.moore.service.StarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/star")
public class StarController {
    @Autowired
    private StarService starService;

    @GetMapping("/add")
    public ResponseData addStar(Long communityId, Long candidateId) {
        int result = starService.addStar(communityId, candidateId);
        if (result > 0) return ResponseData.ok("收藏成功");
        return ResponseData.error("收藏失败");
    }

    @GetMapping("/delete")
    public ResponseData cancelStar(Long communityId, Long candidateId) {
        int result = starService.deleteStar(communityId, candidateId);
        if (result > 0) return ResponseData.ok("取消收藏成功");
        return ResponseData.error("取消收藏失败");
    }
}
